package com.jiawa;

import com.jiawa.wordgz.DownService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/demo")
public class MyController {

    @Autowired
    private DownService downService;

    @GetMapping("/download")
    public void downloadFile(HttpServletResponse response) throws IOException {
        String srcPath = "C:\\Users\\Administrator\\Desktop\\FrameworkContractTemplate.docx";
        String destPath = "C:\\Users\\Administrator\\Desktop\\243合同.docx";
        String firstSealFilePath = "C:\\Users\\Administrator\\Desktop\\321合同.docx";
        String  secondFilePath  = "C:\\Users\\Administrator\\Desktop\\5555合同.docx";
        Map<String, String> map = new HashMap<>();
        map.put("{buyer}", "张三");
        map.put("{seller}", "李四");
        map.put("{buyerAddress}", "应急局");
        map.put("{buyerPhone}", "180000000000");
        map.put("{sellerAddres}", "农贸市场");
        map.put("{sellerPhone}", "190000000000");
        map.put("{priceRate}", "80");
        String firstParty = "C:\\Users\\Administrator\\Desktop\\22.png";
        String partyToB = "C:\\Users\\Administrator\\Desktop\\22.png";
        downService.handleAndDownloadImg( firstParty, partyToB, srcPath, destPath,firstSealFilePath, secondFilePath,map, response);
    }

    @GetMapping("/test")
    public String test() {

        Map<String, String> map = new HashMap<>();
        map.put("<机关地址>", "2333");
        System.out.println(map);
        String number = "123";
        return number;

    }

}